
#include "../general.h"
#include "base.h"

namespace OperationCategory
{
	Base::Base()
	{
		m_pWindow = NULL;
	}

	Base::~Base()
	{
	}

	bool Base::CreateWindow(
		wxWindow *parent, wxWindowID id, 
		const wxPoint &position, const wxSize& size, long style 
		)
	{
		if (m_pWindow)
			return true;

		wxClassInfo* pWindowClassInfo = GetWindowClassInfo();
		m_pWindow = (wxWindow*)pWindowClassInfo->CreateObject();
		return m_pWindow->Create(
			parent, id, position, size, style
			);
	}

	void Base::MoveWindow(const wxRect& rect)
	{
		if (m_pWindow)
		{
			m_pWindow->SetSize(rect);
		}
	}

	void Base::Activate(bool bActivate)
	{
		if (m_pWindow)
		{
			m_pWindow->Show(bActivate);
			if (bActivate)
			{
				m_pWindow->Raise();
			}
		}
	}


	BEGIN_EVENT_TABLE(Base::BaseWindow, wxWindow)
		EVT_WINDOW_CREATE(Base::BaseWindow::OnCreate)
	END_EVENT_TABLE()

	Base::BaseWindow::BaseWindow()
	{
		m_bInOnCreate = false;
	}

	void Base::BaseWindow::OnCreate(wxWindowCreateEvent& event)
	{
		if (m_bInOnCreate)
			return;

		m_bInOnCreate = true;
		CreateControls();
		m_bInOnCreate = false;
	}

	void Base::BaseWindow::CreateControls()
	{
	}
}